/*     */ package com.cr.system.service.impl;
/*     */ 
/*     */ import com.cr.common.utils.MyDateUtils;
/*     */ import com.cr.common.utils.MyStringUtils;
/*     */ import com.cr.system.domain.SysUserOnline;
/*     */ import com.cr.system.mapper.SysUserOnlineMapper;
/*     */ import com.cr.system.service.ISysUserOnlineService;
/*     */ import java.io.Serializable;
/*     */ import java.util.Date;
/*     */ import java.util.Deque;
/*     */ import java.util.List;
/*     */ import org.apache.shiro.cache.Cache;
/*     */ import org.apache.shiro.cache.ehcache.EhCacheManager;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Service;
/*     */ 
/*     */ @Service
/*     */ public class SysUserOnlineServiceImpl implements ISysUserOnlineService {
/*     */   @Autowired
/*     */   private SysUserOnlineMapper userOnlineDao;
/*     */   
/*     */   @Autowired
/*     */   private EhCacheManager ehCacheManager;
/*     */   
/*     */   public SysUserOnline selectOnlineById(String sessionId) {
/*  41 */     return this.userOnlineDao.selectOnlineById(sessionId);
/*     */   }
/*     */   
/*     */   public void deleteOnlineById(String sessionId) {
/*  53 */     SysUserOnline userOnline = selectOnlineById(sessionId);
/*  54 */     if (MyStringUtils.isNotNull(userOnline))
/*  56 */       this.userOnlineDao.deleteOnlineById(sessionId); 
/*     */   }
/*     */   
/*     */   public void batchDeleteOnline(List<String> sessions) {
/*  69 */     for (String sessionId : sessions) {
/*  71 */       SysUserOnline userOnline = selectOnlineById(sessionId);
/*  72 */       if (MyStringUtils.isNotNull(userOnline))
/*  74 */         this.userOnlineDao.deleteOnlineById(sessionId); 
/*     */     } 
/*     */   }
/*     */   
/*     */   public void saveOnline(SysUserOnline online) {
/*  87 */     this.userOnlineDao.saveOnline(online);
/*     */   }
/*     */   
/*     */   public List<SysUserOnline> selectUserOnlineList(SysUserOnline userOnline) {
/*  98 */     return this.userOnlineDao.selectUserOnlineList(userOnline);
/*     */   }
/*     */   
/*     */   public void forceLogout(String sessionId) {
/* 109 */     this.userOnlineDao.deleteOnlineById(sessionId);
/*     */   }
/*     */   
/*     */   public void removeUserCache(String loginName, String sessionId) {
/* 121 */     Cache<String, Deque<Serializable>> cache = this.ehCacheManager.getCache("sys-userCache");
/* 122 */     Deque<Serializable> deque = (Deque<Serializable>)cache.get(loginName);
/* 123 */     if (MyStringUtils.isEmpty(deque) || deque.size() == 0)
/*     */       return; 
/* 127 */     deque.remove(sessionId);
/*     */   }
/*     */   
/*     */   public List<SysUserOnline> selectOnlineByExpired(Date expiredDate) {
/* 138 */     String lastAccessTime = MyDateUtils.parseDateToStr(MyDateUtils.YYYY_MM_DD_HH_MM_SS, expiredDate);
/* 139 */     return this.userOnlineDao.selectOnlineByExpired(lastAccessTime);
/*     */   }
/*     */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-system-4.7.0.jar!\com\cr\system\service\impl\SysUserOnlineServiceImpl.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */